<?php

class halo_ViewHelper {

    static public function RENDER(halo_HttpRequest $httpRequest, halo_HttpResponse $httpResponse, $viewName, $model) {

        $context = halo_DispatcherUtil::GET_CONTEXT($httpRequest);

        $viewResolvers = $context->findStonesByImplementation(
            'halo_IViewResolver'
        );

        $view = null;

        foreach ( $viewResolvers as $viewResolver ) {
            $view = $viewResolver->resolve($viewName, $httpRequest, $httpResponse);
            if ( $view !== null ) break;
        }

        if ( $view !== null ) {
            return $view->render($model, $httpRequest, $httpResponse);
        }

        return null;

    }

}

?>
